// pages/Draft/address/address.js
const app = getApp()
var qianzheng = [{ name: "首页", url:"https://llgc.net.cn/wx/storage/fetch/peet4dwb1buk0h891wxt.jpg" }, { name: "旅游" }, { name: "签证" }, { name: "移民" }, { name: "简历" }, { name: "广告" }, { name: "预留" }, { name: "预留" }, { name: "预留" }, { name: "预留" }]
Page({

  /**
   * 页面的初始数据
   */
  data: {
    navs:[],
    hot:[],
    footer:false,
    userclick: false, //显示使用或预览图层
    look:false,
    modeluser:false,
    address:"福州",
    detail:[],
    ad:[],
    postdata:[],
    detailUrl:''

  },
  hetongclick:function(e){
    console.log(23);
    wx.switchTab({
      url: '../Exam/Exam',
    });
  },
  temclick:function(e){
    wx.switchTab({
      url: '../Exam/Exam',
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    
    // console.log(qianzheng);
    var that = this;
    that.fetchBannerList()
    // this.setData({
    //   postdata:qianzheng
    // })
    if (!app.globalData.userInfo) {
      // console.log(123);
      wx.redirectTo({
        url: '../authorize/authorize',
      })
    };
  },
  fetchBannerList:function(){
    var that = this;
    wx.request({
      url: "http://127.0.0.1:8082/wx/home/index",
      data: {},
      method: "GET",
      header: {
        "Content-Type": "application/json",
        // Cookie: "PHPSESSID=" + wx.getStorageSync("PHPSESSID")
      },
      success: function (a) {
        // console.log(a.data), 0 == a.data && t.WxLogin();
        
        that.setData({
          postdata: a.data.data.banner,
          navs:a.data.data.activity,
          hot: a.data.data.hotGoodsList,
          ad:a.data.data.ad
        });
      
      },
      fail: function (a) {
        // t.WxLogin();
      }
    });
  },
  addresstap: function() {
    wx: wx.navigateTo({
      url: 'address/address',
    })
  },
  searchclick: function() {
    wx: wx.navigateTo({
      url: 'search/search',
    })
  },
  hclick: function () {
    let _that = this;
    if (!_that.data.click) {
      _that.setData({
        footer: false,
      })
    }
  },
  lookclick:function(id){
    let _that = this;
    let pic = id.currentTarget.dataset.url;
    //切换选中合同的详情模版
    _that.setData({

      detailUrl: pic
    })
    let query = id.currentTarget.dataset.id;
    wx.request({
      url: "http://127.0.0.1:8082/wx/goods/detail",
      data: {id:query},
      method: "GET",
      header: {
        "Content-Type": "application/json",
        // Cookie: "PHPSESSID=" + wx.getStorageSync("PHPSESSID")
      },
      success: function (a) {
        wx.setStorageSync('detail', a.data.data.info.fullContent);
        wx.setStorageSync('qdetail', a.data.data.attribute);
        var strjson = a.data.data.info.fullContent
     
          _that.setData({


            detail: a.data.data.info.fullContent

           
        });
        

       

      },
      fail: function (a) {
        // t.WxLogin();
      }
    });

    if (!_that.data.click) {
      _that.setData({
        look: true,
      })
    }
    wx.createSelectorQuery().select('#j_page').boundingClientRect(function (rect) {
      // 使页面滚动到底部
      wx.pageScrollTo({
        scrollTop: 1000
      })
    }).exec()
  },
  userclick:function(){
    let _that = this;
    wx.setStorageSync('htPic', _that.data.detailUrl);
    if (!_that.data.click) {
      _that.setData({
        userclick: false,
        look: false,
        modeluser:false,
        footer:false,
      })
    }
    wx:wx.navigateTo({
      url: 'alertview/alertview?detail='+_that.data.detail,
      success: function(res) {},
      fail: function(res) {},
      complete: function(res) {},
    })
  },
  userhetong:function(){
    let _that = this;
    if (!_that.data.click) {
      _that.setData({
        modeluser: true,
      })
    }
  },
  editclick: function() {
    let _that = this;
    if (!_that.data.click) {
      _that.setData({
        userclick: true,
      })
    }
  },
  fourclick:function(){
    wx.navigateTo({
      url: 'webview/webview',
    })
    // let that = this;
    // if (!that.data.click) {
    //   that.setData({
    //     footer: true,
    //   })
    // }
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})